package com.jiajia.study;

public class Test {
    public static void main(String[] args) {
//        testBasicMethod();
//        testEnsureCapacity();
        testPerson();
    }

    public static void testEnsureCapacity(){
        ArrayList arrayList = new ArrayList(10);
        for (int i = 0; i < 30; i++) {
            arrayList.add(i);
        }
        System.out.println(arrayList);
    }

    public static  void testBasicMethod(){
        ArrayList<Integer> arrayList = new ArrayList<>(10);
        arrayList.add(10);
        arrayList.add(20);
        arrayList.add(30);
        arrayList.add(0,-1);
        System.out.println(arrayList.remove(1));
        System.out.println(arrayList.set(0, 100));
        System.out.println(arrayList.indexOf(30));
        System.out.println(arrayList.contains(30));
        System.out.println(arrayList.size());
        System.out.println(arrayList);
    }
    public static void testPerson(){
        ArrayList<Person> personArrayList = new ArrayList<>(10);

        personArrayList.add(new Person("张三",20));
        personArrayList.add(new Person("李四",30));
        personArrayList.add(new Person("赵六",50));

        System.out.println(personArrayList);
        personArrayList.add(0,new Person("小红",100));
        System.out.println(personArrayList);
        System.out.println(personArrayList.remove(1));
        System.out.println(personArrayList);
        personArrayList.set(0,new Person("小明",18));
        System.out.println(personArrayList);
        System.out.println(personArrayList.indexOf(new Person("李四", 30)));
        System.out.println(personArrayList.contains(new Person("李四", 30)));
        System.out.println(personArrayList.size());


    }
}
